# ${item.logicName}[${item.name}]

## 实体服务对象
实体默认提供服务对象[${sys.getPKGCodeName()}.${item.getPSSystemModule().realCodeName.toLowerCase()}.service.I${item.realCodeName}Service]供外部调用。可在使用代码处进行直接注入：

```java
@Autowired
private I${item.realCodeName}Service i${item.realCodeName}Service;
```
## 使用实体运行时对象[DataEntityRuntime]进行实体功能扩展
运行框架默认使用[${sys.getPKGCodeName()}.${item.getPSSystemModule().realCodeName.toLowerCase()}.dataentity.${item.realCodeName}DERuntime]作为实体的运行时对象，基本代码如下：

```java
package ${sys.getPKGCodeName()}.${item.getPSSystemModule().realCodeName.toLowerCase()}.dataentity;

import java.util.List;
import org.springframework.data.domain.Page;

import net.ibizsys.central.util.annotation.DEDataSet;
import net.ibizsys.central.util.annotation.DEAction;
<% item.getAllPSDEMethodDTOs().each{ %>\
import ${sys.getPKGCodeName()}.${item.getPSSystemModule().realCodeName.toLowerCase()}.dto.${it.realCodeName};
<% } %>\

import ${sys.getPKGCodeName()}.${item.getPSSystemModule().realCodeName.toLowerCase()}.service.I${item.realCodeName}Service;

/**
 * 实体[${item.name}]运行时对象
 * 此代码用户功能扩展代码
 *
 */
public class ${item.realCodeName}DERuntime extends ${sys.getPKGCodeName()}.runtime.dataentity.DataEntityRuntimeBase<${item.getDefaultPSDEMethodDTO().realCodeName}, ${item.getDefaultPSDEFilterDTO().realCodeName}, I${item.realCodeName}Service> {
    private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(${item.realCodeName}DERuntime.class);
}
```
### 扩展行为
<%
item.getAllPSDEActions().each {
    if(it.isEnableBackend()) {
%>\
#### ${it.name}
<% if(it.logicName){ %>${it.logicName}<% } %>
```java
/**
 * 行为：${it.logicName} 调用入口
 * @param ${it.getPSDEActionInput().inputParams}
 * @throws Throwable
 */
public ${it.getPSDEActionReturn().javaType} ${it.realCodeName.uncapitalize()}(${it.getPSDEActionInput().input}) throws Throwable{
<% if(it.getPSDEActionReturn().javaType=="void") { %>\
    this.executeAction(I${item.realCodeName}Service.ACTION_${it.name.toUpperCase()},null,new Object[]{${it.getPSDEActionInput().inputParams}});
<% } else { %>\
    return (${it.getPSDEActionReturn().javaType})this.executeAction(I${item.realCodeName}Service.ACTION_${it.name.toUpperCase()}, null, new Object[] {${it.getPSDEActionInput().inputParams}});
<% } %>\
}

/**
 * 行为：${it.logicName} 实际功能
 * @param ${it.getPSDEActionInput().inputParams}
 * @throws Throwable
 */
@DEAction(I${item.realCodeName}Service.ACTION_${it.name.toUpperCase()})
protected ${it.getPSDEActionReturn().javaType} do${it.realCodeName.capitalize()}Real(${it.getPSDEActionInput().input}) throws Throwable{
<% if(it.getPSDEActionReturn().javaType=="void") { %>\
    this.doExecuteActionReal(I${item.realCodeName}Service.ACTION_${it.name.toUpperCase()}, null, new Object[] {${it.getPSDEActionInput().inputParams}}, null);
<% } else { %>\
    return (${it.getPSDEActionReturn().javaType})this.doExecuteActionReal(I${item.realCodeName}Service.ACTION_${it.name.toUpperCase()}, null, new Object[] {${it.getPSDEActionInput().inputParams}}, null);
<% } %>\
}
```
<%
    }
}
%>\


### 扩展数据集

<%
item.getAllPSDEDataSets().each {
    if(it.isEnableBackend()) {
%>\
#### ${it.name}
<% if(it.logicName){ %>${it.logicName}<% } %>
```java
/**
 * 数据集：${it.logicName} 调用入口
 * @param dto
 * @throws Throwable
 */
public ${it.getPSDEDataSetReturn().javaType} fetch${it.realCodeName.capitalize()}(${it.getPSDEDataSetInput().getPSDEFilterDTO().realCodeName} dto) throws Throwable{
    return (${it.getPSDEDataSetReturn().javaType})this.fetchDataSet(I${item.realCodeName}Service.DATASET_${it.name.toUpperCase()}, null, new Object[] {dto});
}

/**
 * 数据集：${it.logicName} 实际功能
 * @param dto
 * @throws Throwable
 */
@DEDataSet(I${item.realCodeName}Service.DATASET_${it.name.toUpperCase()})
protected ${it.getPSDEDataSetReturn().javaType} doFetch${it.realCodeName.capitalize()}Real(${it.getPSDEDataSetInput().getPSDEFilterDTO().realCodeName} dto) throws Throwable{
    return (${it.getPSDEDataSetReturn().javaType})this.doFetchDataSetReal(I${item.realCodeName}Service.DATASET_${it.name.toUpperCase()}, null, new Object[] {dto}, null);
}
```
<%
    }
}
%>\
## 使用实体逻辑运行时对象[DELogicRuntime]进行实体逻辑扩展

<%
item.getAllPSDELogics().each {
    if(it.isEnableBackend()) {
%>\
#### ${it.name}
<% if(it.memo){ %>${it.memo}<% } %>

```java
package ${sys.getPKGCodeName()}.${item.getPSSystemModule().realCodeName.toLowerCase()}.logic.${item.realCodeName.toLowerCase()};

import net.ibizsys.central.dataentity.logic.IDELogicSession;
import net.ibizsys.model.dataentity.logic.IPSDELogicNode;

import ${sys.getPKGCodeName()}.runtime.dataentity.logic.DELogicRuntimeBase;

public class ${it.realCodeName.capitalize()}DELogicRuntime extends DELogicRuntimeBase{

    private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(${it.realCodeName.capitalize()}DELogicRuntime.class);

    @Override
	protected void onInit() throws Exception {
		super.onInit();
	}

    @Override
    protected void onExecutePSDELogicNode(IDELogicSession iDELogicSession, IPSDELogicNode iPSDELogicNode) throws Throwable {
        String strCodeName = iPSDELogicNode.realCodeName
<% it.getPSDELogicNodes().each {%>\
        if('${it.realCodeName.toUpperCase()}'.equalsIgnoreCase(strCodeName)){
            execute${it.realCodeName.capitalize()}(iDELogicSession)
            return;
        }
<%}%>\
        super.onExecutePSDELogicNode(iDELogicSession, iPSDELogicNode);
    }

<% it.getPSDELogicNodes().each { %>\
    /**
     * 执行逻辑节点[${it.name}]，逻辑类型[${it.getLogicNodeType()}]
     * @param iDELogicSession
     * @param iPSDELogicNode
     * @throws Throwable
     */
    private void execute${it.realCodeName.capitalize()}(IDELogicSession iDELogicSession, IPSDELogicNode iPSDELogicNode) throws Throwable{
        super.onExecutePSDELogicNode(iDELogicSession, iPSDELogicNode, true);
    }

<%}%>\
}

 ```
<%
    }
}
%>\

## 使用实体访问控制对象[DataEntityAccessManager]进行访问控制功能扩展

运行框架默认使用[${sys.getPKGCodeName()}.${item.getPSSystemModule().realCodeName.toLowerCase()}.security.${item.realCodeName}AccessManager]作为实体的访问控制对象，基本代码如下：


```java
package ${sys.getPKGCodeName()}.${item.getPSSystemModule().realCodeName.toLowerCase()}.security;

/**
 * 实体[${item.name}]访问控制对象
 * [用户代码]
 * 
 */
public class ${item.realCodeName}AccessManager extends ${sys.getPKGCodeName()}.runtime.dataentity.security.DataEntityAccessManagerBase{
    private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(${item.realCodeName}AccessManager.class);
}
```